﻿using System.Collections.Generic;
using AutoMapper;
using Sok.Munkae.ApplicationServices.DTO;
using Sok.Munkae.Core;
using Sok.Munkae.Core.DataInterfaces;

namespace Sok.Munkae.ApplicationServices
{
    public interface IProjectService
    {
        IList<ProjectDTO> GetProjectList();
    }

    public class ProjectService : IProjectService
    {
        private IRepository<Project> repository;

        public ProjectService(IProjectRepository repository)
        {
            this.repository = repository;
        }

        #region IProjectService Members

        public IList<ProjectDTO> GetProjectList()
        {
            var dtoList = new List<ProjectDTO>();
            foreach (Project p in repository.GetAll())
            {
                dtoList.Add(Mapper.Map<Project, ProjectDTO>(p));
            }
            return dtoList;
        }

        #endregion
    }
}